package com.module.service.impl;

import com.module.dao.UserInfoMapper;
import com.module.model.UserInfo;
import com.module.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

@Service("userService")
public class UserServiceImpl  implements UserService {

    @Autowired
    private UserInfoMapper userInfoMapper;

    @Override
    public UserInfo getUserById(int id) {
        return this.userInfoMapper.selectByPrimaryKey(Integer.valueOf(id));
    }

    @Override
    public UserInfo getUserByMobile(String mobile) {
        return this.userInfoMapper.selectByMobile(mobile);
    }

    @Override
    public void addUser(UserInfo userInfo) {
        this.userInfoMapper.insert(userInfo);
    }

    @Override
    public int modifyUser(UserInfo userInfo) {
        return this.userInfoMapper.updateByPrimaryKeySelective(userInfo);
    }

    @Override
    public List<Map<String, Object>> list(String name, String beginTime, String endTime) {
        List<Map<String, Object>> data=this.userInfoMapper.selectUsers(name, beginTime, endTime);
        return data;
    }

    @Override
    public UserInfo selectById(int id) {
        return this.userInfoMapper.selectById(id);
    }

    @Override
    public void insert(UserInfo userInfo) {
        this.userInfoMapper.insert(userInfo);
    }

    @Override
    public UserInfo getUserByName(String username) {
        return userInfoMapper.selectByName(username);
    }

    @Override
    public UserInfo authentication(String username, String password) {
        return userInfoMapper.login(username,password);
    }
}